package com.qufadai.framework.orm.jdbc;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;

public class JdbcUtil {
	//cann't construct instance
	private JdbcUtil(){}
	
	public static void closeJdbc(Connection con, Statement st) {
	    try {
	        if(con != null && !con.isClosed()) {
	            con.setAutoCommit(false);
	            if(con.isReadOnly()) {
	                con.setReadOnly(false);
	            }
	            con.close();
	        }
	        if(st != null) {
	            st.close();
	        }
	    } catch(SQLException ex) {
	        ex.printStackTrace();
	    }
	}
	
	public static void closeJdbc(Connection con) {
	    try {
            if(con != null && !con.isClosed()) {
                if(con.isReadOnly()) {
                    con.setReadOnly(false);
                }
                con.close();
            }
        } catch(SQLException ex) {
            ex.printStackTrace();
        }
	}
}
